@extends('layouts.layouts')
@section('title')
    <title>后台首页</title>
    <style>
        .file {
            position: relative;
            display: inline-block;
            background: #D0EEFF;
            border: 1px solid #99D3F5;
            border-radius: 4px;
            padding: 4px 12px;
            overflow: hidden;
            color: #1E88C7;
            text-decoration: none;
            text-indent: 0;
            line-height: 20px;
        }
        .file input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
        }
        .file:hover {
            background: #AADFFD;
            border-color: #78C3F3;
            color: #004974;
            text-decoration: none;
        }
    </style>
@endsection
@section('content')
    <link href="/lib/ueditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" charset="utf-8" src="/lib/ueditor/umeditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/lib/ueditor/umeditor.min.js"></script>
    <script type="text/javascript" src="/lib/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script src="/js/upload.js" type="text/javascript"></script>
    <script src="/js/mobileBUGFix.mini.js" type="text/javascript"></script>
    <link href="/css/ueditor.css" type="text/css" rel="stylesheet">
    <div class="content">
        <div class="header">
            <ul class="breadcrumb">
                <li><a href="/special/index">专题管理</a> </li>
                <li class="active">添加信息</li>
            </ul>
        </div>
        <div class="main-content">
            <ul class="nav nav-tabs nav-tabs-course">
                <li role="presentation" class="course_add active"><a href="javascript:void(0);">添加信息</a></li>
                <!-- <li role="presentation" class="course_hour_add"><a href="javascript:void(0);">课时添加</a></li> -->
            </ul>
            <form class="form-horizontal" id="courseFormInfo" action="/special/store" method="post">
                {{csrf_field()}}
                <div class="course_class row">
                    <div class="col-md-10">
                            <br>
                            <div class="tab-content">
                                
                                <input type="hidden" name="id" value="{{$data->id}}"/>
                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-3 control-label">专题名称</label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" name="title" value="{{$data->title}}" placeholder="专题名称">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputPassword3" class="col-sm-3 control-label">封面图</label>
                                    <div class="col-sm-9">

                                        <a href="javascript:;" class="file">上传封面图(300X182)
                                            <input type="file" class="upload_img cover" name="img_url" placeholder="封面图">
                                        </a>
                                        <img src="{{env('IMG_URL')}}{{$data->img_url}}" id="cover_img" style="width:120px;max-height:120px;">
                                        <input type="hidden" class="cover_img" name="img_url" value="{{$data->img_url}}"/>
                                    </div>
                                </div>
                                 <div class="form-group">
                                    <label for="inputPassword3" class="col-sm-3 control-label">海报</label>
                                    <div class="col-sm-9">

                                        <a href="javascript:;" class="file">上传海报
                                            <input type="file" class="upload_img1 bill" name="bill_url" placeholder="海报图">
                                        </a>
                                        <img src="{{env('IMG_URL')}}{{$data->img_url}}" id="bill_img" style="width:120px;max-height:120px;">
                                        <input type="hidden" class="bill_img" name="bill_url" value="{{$data->bill_url}}"/>
                                    </div>
                                </div>    

                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-3 control-label">信息排序值</label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" name="orderby" placeholder="信息排序值" value="{{$data->orderby}}">
                                        
                                    </div>
                                    <b>(排序值从大到小排序,最小为0)</b>
                                </div>
                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-3 control-label">喜欢人数</label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" value="{{$data->likes}}" name="likes" placeholder="喜欢人数"> 
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-3 control-label">关注人数</label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" value="{{$data->view}}" name="view" placeholder="关注人数"> 
                                    </div>
                                </div>


                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-3 control-label">专题集数</label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" value="{{$data->count_special}}" name="count_special" placeholder="专题集数">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputPassword3" class="col-sm-3 control-label">专题简述</label>
                                    <div class="col-sm-8">
                                        <textarea type="text/plain" class="form-control" placeholder="" id="description" name="jianshu">{{$data->jianshu}}</textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputPassword3" class="col-sm-3 control-label">专题详述</label>
                                    <div class="col-sm-8">
                                        <textarea type="text/plain" class="form-control" placeholder="" id="description" name="description">{{$data->description}}</textarea>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-3 control-label">seo标题</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="seo_title" value = "{{$data->seo_title}}" placeholder="seo标题">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-3 control-label">seo描述</label>
                                    <div class="col-sm-8">
                                        <textarea type="text/plain" class="form-control"  placeholder="seo描述" name="seo_description">{{$data->seo_description}}</textarea>
                                    </div>
                                </div>
                                
                                 
                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-3 control-label">专题小结</label>
                                    <div class="col-sm-8">
                                        <textarea type="text/plain" class="form-control" placeholder="专题小结" name="result">{{$data->result}}</textarea>
                                    </div>
                                </div>
                            </div>
                    </div>
                </div>
                <div class="row">
                    <p>
                        <button type="submit" class="btn btn-primary col-md-offset-5" style="width:120px;background:#286090;color:#fff;">提交</button>
                    </p>
                </div>
            </form>
            <br/>
            <br/>    
        </div>
    </div>
    
    <script src="/js/ueditor.js"></script>
    <script src="/js/course.js"></script>
    <script src="/lib/jquery.validate.js" type="text/javascript"></script>
    <script>

        var imgUrl = '{{env('IMG_URL')}}';
        $(".upload_img").UploadImg({
            url : '/course/fileUpload',
            // width : '320',
            //height : '200',
            quality : '0.8', //压缩率，默认值为0.8
            // 如果quality是1 宽和高都未设定 则上传原图
            mixsize : '10000000',
            //type : 'image/png,image/jpg,image/jpeg,image/pjpeg,image/gif,image/bmp,image/x-png',
            before : function(blob,className){
//                var className = '#'+className;
//                $(className).attr('src',blob);
            },
            error : function(res){
                $('#img').attr('src','');
                $('#error').html(res);
            },
            success : function(url,className){
                var idName = '#'+className;
                var className = '.'+className;
                $(idName).attr('src',imgUrl+url);
                $(className).val(url);
            }
        });
        $(".upload_img1").UploadImg({
            url : '/course/fileUpload',
            // width : '320',
            //height : '200',
            quality : '0.8', //压缩率，默认值为0.8
            // 如果quality是1 宽和高都未设定 则上传原图
            mixsize : '10000000',
            //type : 'image/png,image/jpg,image/jpeg,image/pjpeg,image/gif,image/bmp,image/x-png',
            before : function(blob,className){
//                var className = '#'+className;
//                $(className).attr('src',blob);
            },
            error : function(res){
                $('#img').attr('src','');
                $('#error').html(res);
            },
            success : function(url,className){
                var idName = '#'+"bill_img";

                var className = '.'+ "bill_img";
                $(idName).attr('src',imgUrl+url);
                $(className).val(url);
            }
        });
        // $("#courseFormInfo").validate({
        //     onsubmit: true,// 是否在提交是验证
        //     submitHandler: function (form) {
        //         var title = $("input[name='title']").val();
        //         var types = $("input[name='types[]']:checked").val();
        //         var tags = $("input[name='tags[]']:checked").val();
        //         var cover_url = $("input[name='cover_url']").val();
        //         var description = $("#description").val();
        //         var seo_title   = $("input[name='seo_title']").val();
        //         var seo_description   = $("input[name='seo_description']").val();
        //         if(title == ''){
        //             swal("文章名称未录入!");
        //             return false;
        //         }
        //         if(!types){
        //             swal("未选择信息分类!");
        //             return false;
        //         }
        //         if(!tags){
        //             swal("未选择标签");
        //             return false;
        //         }
        //         if(cover_url == ''){
        //             swal("未上传封面图");
        //             return false;
        //         }
                
        //         if(description == ''){
        //             swal('未填写描述');
        //             return false;
        //         }
        //         if(seo_title == ''){
        //             swal('未填写seo_标题');
        //             return false;
        //         }
        //         if(seo_description == ''){
        //             swal('未填写seo_描述');
        //             return false;
        //         }
        //         form.submit();
        //     }
        // });
    </script>
    <style type="text/css">
        .col-sm-2{
            width:60px;
        }
        .course_content{
            margin-right: -30px;
            margin-left: -30px;
            margin-top:5px;
        }
        .btn-success{
            background-image:none!important;
        }
    </style>
@endsection